package com.bwie.controller;

import com.bwie.common.pojo.dto.GoodsDto;
import com.bwie.common.result.Result;
import com.bwie.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@CrossOrigin
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    /**
     * 获取商品列表
     * @param goodsDto
     * @return
     */
    @PostMapping("/getGoodsList")
    private Result getGoodsList(@RequestBody GoodsDto goodsDto){
        return goodsService.getGoodsList(goodsDto);
    }
    /**
     * 商品新增
     */
    @PostMapping("goodsAdd")
    private Result goodsAdd(@RequestBody GoodsDto goodsDto){
        return goodsService.goodsAdd(goodsDto);
    }

    /**
     * 审核
     */
    @PostMapping("audit")
    private Result audit(@RequestBody GoodsDto goodsDto){
        return goodsService.audit(goodsDto);
    }
    /**
     * 删除
     */
    @PostMapping("del")
    private Result del(@RequestBody GoodsDto goodsDto){
        return goodsService.del(goodsDto);
    }
    /**
     * 购买
     */
    @PostMapping("pay")
    private Result pay(@RequestBody GoodsDto goodsDto){
        return goodsService.pay(goodsDto);
    }
    @PostMapping("buy")
    private Result buy(@RequestBody GoodsDto goodsDto){
        return goodsService.buy(goodsDto);
    }

    /**
     * 导出
     */
    @PostMapping("out")
    private void out() {
        goodsService.out();
    }
    /**
     * 导入
     */
    @PostMapping("insert")
    private void insert(@RequestParam("file") MultipartFile file){
        goodsService.insert(file);
    }
}
